#!/usr/bin/env python3
import requests
import json
import argparse

__author__ = "Corsin Camichel"
__copyright__ = "Copyright 2020, Corsin Camichel"
__license__ = "Creative Commons Attribution-ShareAlike 4.0 International License."
__version__ = "1.0"
__email__ = "cocaman@gmail.com"

parser = argparse.ArgumentParser(description='Add a comment to a sample on Malware Bazaar by abuse.ch')
parser.add_argument('-s', '--hash', help='Hash of the file (required)', type=str, metavar="HASH", required=True)
parser.add_argument('-c', '--comment', help='Comment to add (required)', type=str, metavar="COMMENT", required=True)
args = parser.parse_args()

headers = { 'API-KEY': '' }

data = {
    'query': 'add_comment',
    'sha256_hash': ''+args.hash+'',
    'comment': u''+args.comment+''
}

response = requests.post('https://mb-api.abuse.ch/api/v1/', data=data, timeout=15, headers=headers)
print(response.content.decode("utf-8", "ignore"))
